using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Yunwei.Domain.Models.Mapping
{
    public class ArticalMap : EntityTypeConfiguration<Artical>
    {
        public ArticalMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.SubTitle)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.ArticalContent)
                .IsRequired();

            this.Property(t => t.Author)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Artical");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.SubTitle).HasColumnName("SubTitle");
            this.Property(t => t.ArticalContent).HasColumnName("ArticalContent");
            this.Property(t => t.Author).HasColumnName("Author");
            this.Property(t => t.PubTime).HasColumnName("PubTime");
            this.Property(t => t.EditTime).HasColumnName("EditTime");
        }
    }
}
